package com.xiaoyun.xpath;


import com.xiaoyun.xpath.handler.field.*;

/**
 * 内部策略映射
 */
public enum TypeNameStrategy {
    //顺序 不能乱
    MAP("Map", MapFieldHandler.class),
    LIST("List", ListFieldHandler.class),
    INTEGER("Integer", IntegerFieldHandler.class),
    DATE("Date", DateFieldHandler.class),
    STRING("String", StringFieldHandler.class);

    private String typeName;
    private Class clazz;

    public static Class getEnumType(String key) {
        TypeNameStrategy[] strategies = values();
        for (TypeNameStrategy typeNameStrategy : strategies) {
            if (key.contains(typeNameStrategy.typeName)) {
                return typeNameStrategy.clazz;
            }
        }
        return null;
    }

    public String getTypeName() {
        return typeName;
    }

    public Class getClazz() {
        return clazz;
    }

    TypeNameStrategy(String typeName, Class clazz) {
        this.typeName = typeName;
        this.clazz = clazz;
    }
}
